app.controller('baseController', function ($scope) {

    //传递参数并且调用分页查询数据方法
    $scope.reloadList = function () {
        $scope.findPage($scope.paginationConf.currentPage, $scope.paginationConf.itemsPerPage);
    };

    //分页控件配置--死写法
    $scope.paginationConf = {
        currentPage: 1,
        totalItems: 10,
        itemsPerPage: 10,
        perPageOptions: [10, 20, 30, 40, 50],
        onChange: function () {
            //重新加载,此方法将会被自动加载
            //1,页面刷新
            //2,分页控件中数据发生变化，reloadList也会自动调用
            $scope.reloadList();
        }
    };

    //    更新复选框
    $scope.selectIds = [];
    $scope.updateSelection = function ($event,id) {
        if($event.target.checked){
            $scope.selectIds.push(id);
        }else {
            var idx = $scope.selectIds.indexOf(id);
            $scope.selectIds.splice(idx,1);
        }
    };

    $scope.jsonToStr = function (jsonStr, key) {
        var typeJson = JSON.parse(jsonStr);
        var value = "";
        for(var i =0;i<typeJson.length;i++){
            if(i>0){
                value += ", ";
            }
            value += typeJson[i][key];
        }
        return value;
    }
});